<%@ page contentType="text/html;charset=UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="tags" tagdir="/WEB-INF/tags"%>
<%@taglib prefix="shiro" uri="http://shiro.apache.org/tags"%>
<c:set var="ctx" value="${pageContext.request.contextPath}" />
<html>
<head>
<title>修改密码</title>
<script type="text/javascript">
	$(function() {
		$('#messageCenter2').css('display', 'none');
		$('#messageCenter3').css('display', 'none');
		$.extend($.fn.validatebox.defaults.rules, {
			equals : {
				validator : function(value, param) {
					return value == $(param[0]).val();
				},
				message : '二次的输入新密码不一致'
			}

		});
		$('#submit').bind('click', function(row) {
			var newPassword = $("#newPassword").val();
			var newPasswordA = $("#newPasswordA").val();
			var success;
			if (newPassword == 0 && newPasswordA == 0) {
				return;
			}
			$("#newPassword").val("");
			$("#newPasswordA").val("");
			$.post("${ctx}/basic/userValidate/validateUser", {
				email : '${email}',
				validateCode : '${validateCode}',
				newPassword : newPassword,
			}, function(data) {
				showInfo(data.obj);
				if (data.success) {
					$('#messageCenter2').css('display', 'block');
					$('#messageCenter3').css('display', 'none');
					$('#messageCenter').css('display', 'none');
				} else {
					$('#messageCenter3').css('display', 'block');
					$('#messageCenter2').css('display', 'none');
					$('#messageCenter').css('display', 'none');
				}
			}, "json");
		});

		$('#reset').bind('click', function(row) {
			$("#newPassword").val("");
			$("#newPasswordA").val("");
		});

	});
</script>
</head>

<body>
	<div align="center" id="messageCenter">
		<div class="panel panel-primary" style="width: 500px; height: 350px; padding: 50px;" align="center">
			<div class="panel-heading" align="center">密码修改</div>

			<div class="panel-body" align="center" style="padding: 30px;">
				<form>
					<table class="table-condensed">
						<tr>
							<td><label>新&nbsp;&nbsp;&nbsp;&nbsp;密&nbsp;&nbsp;&nbsp;码：</label></td>
							<td><input id="newPassword" name="newPassword" type="password" class="easyui-validatebox" required="required"></td>
						</tr>
						<tr>
							<td><label>请重复输入密码：</label></td>
							<td><input id="newPasswordA" name="newPasswordA" type="password" class="easyui-validatebox" validType="equals['#newPassword']"
								required="required"></td>
						</tr>
					</table>
				</form>
			</div>

			<div class="panel-footer" align="right">
				<button id="submit" class="btn btn-primary" type="button">
					<span class="glyphicon glyphicon-ok"></span> 提交
				</button>
				<button id="reset" class="btn btn-primary" type="button">
					<span class="glyphicon glyphicon-refresh"></span> 重置
				</button>
			</div>

		</div>
	</div>

	<!-- 提示信息 -->
	<div id="messageCenter2" align="center" style="padding: 50px">
		<div class="panel panel-info" style="width: 600px; height: 350px; padding: 50px;" align="center">
			<div align="center">
				<form id="x-form">
					<table class="table-condensed">
						<tr>
							<td align="center"><img alt="" src="../../static/image/ok.png"></td>
						</tr>
						<tr>
							<td align="center"><h4>
									密码修改成功!
									</h4></td>
						</tr>
					</table>
				</form>
			</div>
		</div>
	</div>

	<div id="messageCenter3" align="center" style="padding: 50px">
		<div class="panel panel-info" style="width: 600px; height: 350px; padding: 50px;" align="center">
			<div align="center">
				<form id="x-form">
					<table class="table-condensed">
						<tr>
							<td align="center"><img alt="" src="../../static/image/warning.png"></td>
						</tr>
						<tr>
							<td align="center"><h4>
									密码修改失败!
									</h4></td>
						</tr>
					</table>
				</form>
			</div>
		</div>
	</div>
</body>
</html>